#!/bin/bash

ulimit -c unlimited -n 8192

SERVER=`pwd | awk -F/ '{print $4}'`

if [ "${SERVER}" == "" ]
then
        echo "path error!"
        exit 1
fi

PID=`ps aux | grep engine | grep -v grep | grep ${SERVER} | awk '{print $2}'`

if [ "${PID}" != "" ]
then
        echo "Process engine ${SERVER} exists, exit"
        exit 1
fi


echo "Start engine..."
nohup ./engine ${SERVER} > nohup.engine.out &

sleep 4
if ps aux | grep engine | grep --color=always ${SERVER} 
then
	echo 
	echo "Game server start ok! ${SERVER} "
fi
